From 760c78d509bd9c0867e33a6116c5c645091b2087 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Thu, 17 Jan 2008 12:05:43 -0700 Subject: [PATCH] [IA64] domheap: Allocate vm buffer before boot allocator Signed-off-by: Isaku Yamahata --- xen/arch/ia64/linux-xen/setup.c | 12 +---------- xen/arch/ia64/vmx/vmx_init.c | 37 ++++++++++++++++++++++++--------- xen/arch/ia64/xen/xensetup.c | 11 ++++++++++ xen/include/asm-ia64/vmx.h | 2 +- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/xen/arch/ia64/linux-xen/setup.c b/xen/arch/ia64/linux-xen/setup.c index 6a0964534c..882f7b1e20 100644 --- a/xen/arch/ia64/linux-xen/setup.c +++ b/xen/arch/ia64/linux-xen/setup.c @@ -561,10 +561,10 @@ late_setup_arch (char **cmdline_p) #endif #ifndef XEN find_memory(); -#endif /* process SAL system table: */ ia64_sal_init(efi.sal_systab); +#endif #ifdef CONFIG_SMP #ifdef XEN @@ -587,10 +587,6 @@ late_setup_arch (char **cmdline_p) smp_num_siblings); #endif -#ifdef XEN - identify_vmx_feature(); -#endif - cpu_init(); /* initialize the bootstrap CPU */ #ifdef CONFIG_ACPI_BOOT @@ -803,12 +799,6 @@ identify_cpu (struct cpuinfo_ia64 *c) } c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1)); c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1)); - -#ifdef XEN - /* If vmx feature is on, do necessary initialization for vmx */ - if (vmx_enabled) - vmx_init_env(); -#endif } void diff --git a/xen/arch/ia64/vmx/vmx_init.c b/xen/arch/ia64/vmx/vmx_init.c index 523c2cd6d4..69010cf6ac 100644 --- a/xen/arch/ia64/vmx/vmx_init.c +++ b/xen/arch/ia64/vmx/vmx_init.c @@ -56,7 +56,6 @@ /* Global flag to identify whether Intel vmx feature is on */ u32 vmx_enabled = 0; -static u32 vm_order; static u64 buffer_size; static u64 vp_env_info; static u64 vm_buffer = 0; /* Buffer required to bring up VMX feature */ @@ -97,8 +96,7 @@ identify_vmx_feature(void) /* Does xen has ability to decode itself? */ if (!(vp_env_info & VP_OPCODE)) printk("WARNING: no opcode provided from hardware(%lx)!!!\n", vp_env_info); - vm_order = get_order(buffer_size); - printk("vm buffer size: %ld, order: %d\n", buffer_size, vm_order); + printk("vm buffer size: %ld\n", buffer_size); vmx_enabled = 1; no_vti: @@ -110,16 +108,33 @@ no_vti: * vsa_base is the indicator whether it's first LP to be initialized * for current domain. */ -void -vmx_init_env(void) +void* +vmx_init_env(void *start, unsigned long end_in_pa) { u64 status, tmp_base; if (!vm_buffer) { - vm_buffer = (unsigned long)alloc_xenheap_pages(vm_order); - ASSERT(vm_buffer); - vm_buffer = virt_to_xenva((vm_buffer)); - printk("vm_buffer: 0x%lx\n", vm_buffer); + /* VM buffer must must be 4K aligned and + * must be pinned by both itr and dtr. */ +#define VM_BUFFER_ALIGN (4 * 1024) +#define VM_BUFFER_ALIGN_UP(x) (((x) + (VM_BUFFER_ALIGN - 1)) & \ + ~(VM_BUFFER_ALIGN - 1)) + unsigned long s_vm_buffer = + VM_BUFFER_ALIGN_UP((unsigned long)start); + unsigned long e_vm_buffer = s_vm_buffer + buffer_size; + if (__pa(e_vm_buffer) < end_in_pa) { + init_xenheap_pages(__pa(start), __pa(s_vm_buffer)); + start = (void*)e_vm_buffer; + vm_buffer = virt_to_xenva(s_vm_buffer); + printk("vm_buffer: 0x%lx\n", vm_buffer); + } else { + printk("Can't allocate vm_buffer " + "start 0x%p end_in_pa 0x%lx " + "buffer_size 0x%lx\n", + start, end_in_pa, buffer_size); + vmx_enabled = 0; + return start; + } } status=ia64_pal_vp_init_env(__vsa_base ? VP_INIT_ENV : VP_INIT_ENV_INITALIZE, @@ -129,7 +144,8 @@ vmx_init_env(void) if (status != PAL_STATUS_SUCCESS) { printk("ia64_pal_vp_init_env failed.\n"); - return ; + vmx_enabled = 0; + return start; } if (!__vsa_base) @@ -137,6 +153,7 @@ vmx_init_env(void) else ASSERT(tmp_base == __vsa_base); + return start; } typedef union { diff --git a/xen/arch/ia64/xen/xensetup.c b/xen/arch/ia64/xen/xensetup.c index 79fd5420d7..daae981f76 100644 --- a/xen/arch/ia64/xen/xensetup.c +++ b/xen/arch/ia64/xen/xensetup.c @@ -30,6 +30,7 @@ #include #include #include +#include unsigned long xenheap_phys_end, total_pages; @@ -456,6 +457,16 @@ void __init start_kernel(void) trap_init(); + /* process SAL system table */ + /* must be before any pal/sal call */ + ia64_sal_init(efi.sal_systab); + + /* early_setup_arch() maps PAL code. */ + identify_vmx_feature(); + /* If vmx feature is on, do necessary initialization for vmx */ + if (vmx_enabled) + xen_heap_start = vmx_init_env(xen_heap_start, xenheap_phys_end); + init_xenheap_pages(__pa(xen_heap_start), xenheap_phys_end); printk("Xen heap: %luMB (%lukB)\n", (xenheap_phys_end-__pa(xen_heap_start)) >> 20, diff --git a/xen/include/asm-ia64/vmx.h b/xen/include/asm-ia64/vmx.h index f17cd5785e..8e64cf8368 100644 --- a/xen/include/asm-ia64/vmx.h +++ b/xen/include/asm-ia64/vmx.h @@ -29,7 +29,7 @@ extern void identify_vmx_feature(void); extern unsigned int vmx_enabled; -extern void vmx_init_env(void); +extern void *vmx_init_env(void *start, unsigned long end_in_pa); extern int vmx_final_setup_guest(struct vcpu *v); extern void vmx_save_state(struct vcpu *v); extern void vmx_load_state(struct vcpu *v); -- 2.30.2